package sunbao.ido.config;

import com.alipay.jarslink.api.ModuleConfig;
import com.alipay.jarslink.api.impl.AbstractModuleRefreshScheduler;
import com.google.common.collect.ImmutableList;

import java.net.URL;
import java.util.Arrays;
import java.util.List;

/**
 * @Classname ModuleRefreshSchedulerImpl
 * @Description
 * @Date 2020/05/22 18:45
 * @Created by Administrator
 */
public class ModuleRefreshSchedulerImpl extends AbstractModuleRefreshScheduler {

    @Override
    public List<ModuleConfig> queryModuleConfigs() {
        return ImmutableList.of(buildModuleConfig());
    }

    public static ModuleConfig buildModuleConfig() {
        URL demoModule = Thread.currentThread().getContextClassLoader().getResource("META-INF/com.demo-1.0-SNAPSHOT-jar-with-dependencies.jar");
        ModuleConfig moduleConfig = new ModuleConfig();
        //通过该方法构建的配置都是使用注解形式扫描bean的
        moduleConfig.setOverridePackages(Arrays.asList("com.demo.jarslink"));
        moduleConfig.setName("demo");
        moduleConfig.setEnabled(true);
        moduleConfig.setVersion("0.0.1");
        moduleConfig.setModuleUrl(ImmutableList.of(demoModule));
        return moduleConfig;
    }

}
